import React from "react";
import styles from "./index.module.scss";
type Props = {
  onClose: () => void;
  type: "" | "gender" | "photo";
  value: string;
  onUpdateProfile: (type: "gender" | "photo", value: string) => void;
};
//   性别
const genderList = [
  { text: "男", value: "0" },
  { text: "女", value: "1" },
];
const photoList = [
  { text: "拍照", value: "picture" },
  { text: "本地选择", value: "local" },
];
function EditList({ onClose, type, onUpdateProfile }: Props) {
  const list = type === "gender" ? genderList : photoList;
  const onItemClick = (value: string) => {
    if (type === "") return;
    onUpdateProfile(type, value);
    console.log(value, type);
  };

  return (
    <div className={styles.root}>
      {list.map((item: any) => (
        <div
          className="list-item"
          key={item.text}
          onClick={() => {
            if (type === "") return;
            onUpdateProfile(type, item.value);
          }}
        >
          {item.text}
        </div>
      ))}
      {/* <div className="list-item" onClick={() => onItemClick("0")}>
        男
      </div>
      <div className="list-item" onClick={() => onItemClick("1")}>
        女
      </div> */}
      <div className="list-item" onClick={onClose}>
        取消
      </div>
    </div>
  );
}

export default EditList;
